import {
  Controller,
  Get,
  Post,
  Body,
  Put,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { OrderService } from './order.service';
import { CreateOrderDto } from './dto/create-order.dto';
import { UpdateOrderDto } from './dto/update-order.dto';
import { ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';

@Controller('order')
@ApiTags('订单管理')
export class OrderController {
  constructor(private readonly orderService: OrderService) {}

  @Post()
  create(@Body() createOrderDto: CreateOrderDto) {
    return this.orderService.create(createOrderDto);
  }

  @Get()
  findAll() {
    return this.orderService.findAll();
  }

  // 分页查询
  @Get('/skip')
  @ApiOperation({
    summary: '分页查询',
    description: '分页查管理员所在地区的用户信息',
  })
  @ApiQuery({ name: 'pageSize', description: '数据条数', required: true })
  @ApiQuery({ name: 'currentPage', description: '当前页码', required: true })
  @ApiQuery({ name: 'city', description: '城市', required: true })
  @ApiQuery({ name: 'keywords', description: '关键词', required: false })
  skipFind(
    @Query('currentPage') currentPage,
    @Query('pageSize') pageSize,
    @Query('city') city,
    @Query('keywords') keywords,
  ) {
    return this.orderService.skipFind(+currentPage, +pageSize, city, keywords);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.orderService.findOne(+id);
  }

  @Put(':id')
  update(@Param('id') id: string, @Body() params: any) {
    return this.orderService.update(+id, params);
  }

  @Delete('/delete')
  remove(@Body() ids: number[]) {
    return this.orderService.remove(ids);
  }
}
